package com.coolingme.springframework.aop.aspect;

import com.coolingme.springframework.aop.intercept.MeMethodInterceptor;
import com.coolingme.springframework.aop.intercept.MeMethodInvocation;

import java.lang.reflect.Method;

/**
 * @author wangyue
 * @date 2024/09/10 22:18
 */
public class MeAspectJAfterThrowingAdvice extends MeAbstractAspectJAdvice implements MeMethodInterceptor {
    private String throwName;

    public MeAspectJAfterThrowingAdvice(Object aspect, Method adviceMethod) {
        super(aspect, adviceMethod);
    }

    @Override
    public Object invoke(MeMethodInvocation mi) throws Throwable {
        try {
            return mi.proceed();
        } catch (Throwable ex) {
            invokeAdviceMethod(mi, null, ex);
            throw ex;
        }
    }

    public void setThrowName(String throwName) {
        this.throwName = throwName;
    }
}
